package org.xinjiang.data.migration.flush.controller;

import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xinjiang.data.migration.common.response.Param;
import org.xinjiang.data.migration.common.response.Result;
import org.xinjiang.data.migration.flush.dto.res.FlushResultDTO;
import org.xinjiang.data.migration.flush.service.IJDcpgFlushService;
import org.xinjiang.data.migration.xinjiang.dto.req.XjDcpgQueryDTO;

/**
 * @Description: 调查评估同步刷数据
 */
@Api(tags = "调查评估同步刷数据")
@RestController
@RequestMapping("/flush/dcpg")
@Slf4j
public class DcpgFlushController {
    @Autowired
    private IJDcpgFlushService dcpgFlushService;

    /**
     * 分页刷数据
     *
     * @return Void
     */
    @Operation(summary = "全量分页刷数据刷数据")
    @PostMapping(value = "/execute-part")
    public Result<FlushResultDTO> executePart(Param pageable, @Validated @RequestBody XjDcpgQueryDTO dto) {
        FlushResultDTO result = dcpgFlushService.flush(pageable, dto);
        return Result.ok(result);
    }

    /**
     * 全量刷数据
     *
     * @return Void
     */
    @Operation(summary = "全量刷数据")
    @PostMapping(value = "/execute-all")
    public Result<FlushResultDTO> executeAll(@Validated @RequestBody XjDcpgQueryDTO dto) {
        FlushResultDTO result = dcpgFlushService.flushAll(dto);
        return Result.ok(result);
    }
}
